<html>
<head>
	<title></title>
</head>
<body>

	<form enctype="multipart/form-data" action="file_upload.php" method="POST">
	    <input type="hidden" name="MAX_FILE_SIZE" value="20000" />
	        Choose a file to upload: <input name="uploadedfile" type="file" />
	    <br />
	    <input type="submit" name="upload" value="Upload File" />
	</form>

<?php

if (isset($_REQUEST['upload'])) {
include_once('Zend/File/Transfer/Adapter/Http.php');

$upload = new Zend_File_Transfer_Adapter_Http();

$upload->addValidator('Size', false, '20kB');
$upload->addValidator('Count', false, 1);
$upload->addValidator('Extension', false, 'csv, txt');
$upload->setDestination('./upload');
	
if (!$upload->isValid()) {
    
	$earray = $upload->getMessages();
	if (isset($earray['fileUploadErrorNoFile'])) echo 'No file uploaded - use browse button to select a file for upload';
	if (isset($earray['fileExtensionFalse'])) echo 'No file uploaded - file extension has to be "csv" or "txt"';
	if (isset($earray['fileUploadErrorFormSize'])) echo 'No file uploaded - the file has to be < 20kB';
	echo "\n</body>\n</html>";
	exit;
}

try {
   $upload->receive();
   $names = $upload->getFileName();
   list($c, $d, $f) = split('/', $names);
   echo 'File \''.$f. '\' successfully uploaded!<br/>';
} catch (Zend_File_Transfer_Exception $e) {
    $e->getMessage();
	echo "\n</body>\n</html>";
	exit;
}
include 'process_file.php';
}

?>
</body>
</html>